home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / xschem28.lzh / SRC / XSFTAB.C < prev    next >
C/C++ Source or Header  |  1991-09-16  |  13KB  |  486 lines

  1. /* xsftab.c - built-in function table */
  2. /*    Copyright (c) 1988, by David Michael Betz
  3.     All Rights Reserved
  4.     Permission is granted for unrestricted non-commercial use    */
  5.  
  6. #include "xscheme.h"
  7.  
  8. /* external variables */
  9. extern LVAL s_stdin,s_stdout;
  10.  
  11. /* external functions */
  12. extern void
  13.     xapply(),xcallcc(),xmap(),xmap1(),xforeach(),xforeach1(),
  14.     xforce(),xforce1(),xcallwi(),xcallwo(),xwithfile1(),
  15.     xload(),xloadnoisily(),xload1(),xsendsuper(),clnew();
  16. extern LVAL
  17.     clisnew(),clanswer(),obisnew(),obclass(),obshow(),
  18.     xcons(),xcar(),xcdr(),
  19.     xcaar(),xcadr(),xcdar(),xcddr(),
  20.     xcaaar(),xcaadr(),xcadar(),xcaddr(),
  21.     xcdaar(),xcdadr(),xcddar(),xcdddr(),
  22.     xcaaaar(),xcaaadr(),xcaadar(),xcaaddr(),
  23.     xcadaar(),xcadadr(),xcaddar(),xcadddr(),
  24.     xcdaaar(),xcdaadr(),xcdadar(),xcdaddr(),
  25.     xcddaar(),xcddadr(),xcdddar(),xcddddr(),
  26.     xsetcar(),xsetcdr(),xlist(),xliststar(),
  27.     xappend(),xreverse(),xlastpair(),xlength(),xlistref(),xlisttail(),
  28.     xmember(),xmemv(),xmemq(),xassoc(),xassv(),xassq(),
  29.     xsymvalue(),xsetsymvalue(),xsymplist(),xsetsymplist(),xgensym(),
  30.     xboundp(),xget(),xput(),
  31.     xtheenvironment(),xprocenvironment(),xenvp(),xenvbindings(),xenvparent(),
  32.     xvector(),xmakevector(),xvlength(),xvref(),xvset(),
  33.     xvectlist(),xlistvect(),
  34.     xmakearray(),xaref(),xaset(),
  35.     xsymstr(),xstrsym(),
  36.     xnull(),xatom(),xlistp(),xnumberp(),xbooleanp(),
  37.     xpairp(),xsymbolp(),xintegerp(),xrealp(),xcharp(),xstringp(),xvectorp(),
  38.     xprocedurep(),xobjectp(),xdefaultobjectp(),
  39.     xinputportp(),xoutputportp(),xportp(),
  40.     xeq(),xeqv(),xequal(),
  41.     xzerop(),xpositivep(),xnegativep(),xoddp(),xevenp(),
  42.     xexactp(),xinexactp(),
  43.     xadd1(),xsub1(),xabs(),xgcd(),xrandom(),
  44.     xadd(),xsub(),xmul(),xdiv(),xquo(),xrem(),xmin(),xmax(),
  45.     xsin(),xcos(),xtan(),xasin(),xacos(),xatan(),
  46.     xxexp(),xsqrt(),xexpt(),xxlog(),xtruncate(),xfloor(),xceiling(),xround(),
  47.     xlogand(),xlogior(),xlogxor(),xlognot(),
  48.     xlss(),xleq(),xeql(),xgeq(),xgtr(),
  49.     xstrlen(),xstrnullp(),xstrappend(),xstrref(),xsubstring(),
  50.     xstrlist(),xliststring(),
  51.     xstrlss(),xstrleq(),xstreql(),xstrgeq(),xstrgtr(),
  52.     xstrilss(),xstrileq(),xstrieql(),xstrigeq(),xstrigtr(),
  53.     xcharint(),xintchar(),
  54.     xchrlss(),xchrleq(),xchreql(),xchrgeq(),xchrgtr(),
  55.     xchrilss(),xchrileq(),xchrieql(),xchrigeq(),xchrigtr(),
  56.     xread(),xrdchar(),xrdbyte(),xrdshort(),xrdlong(),xeofobjectp(),
  57.     xwrite(),xwrchar(),xwrbyte(),xwrshort(),xwrlong(),
  58.     xdisplay(),xnewline(),xprint(),xprbreadth(),xprdepth(),
  59.     xopeni(),xopeno(),xopena(),xopenu(),xclosei(),xcloseo(),xclose(),
  60.     xgetfposition(),xsetfposition(),xcurinput(),xcuroutput(),
  61.     xtranson(),xtransoff(),xgetarg(),xexit(),xcompile(),xdecompile(),xgc(),
  62.     xsave(),xrestore(),xtraceon(),xtraceoff(),xreset(),xerror(),
  63.     xicar(),xicdr(),xisetcar(),xisetcdr(),xivlength(),xivref(),xivset();
  64.  
  65. /* include machine specific declarations */
  66. #include "osdefs.h"
  67.  
  68. int xsubrcnt = 12;    /* number of XSUBR functions */
  69. int csubrcnt = 17;    /* number of CSUBR functions + xsubrcnt */
  70.  
  71. typedef LVAL (*FP)();
  72.  
  73. /* built-in functions */
  74. FUNDEF funtab[] = {
  75.  
  76.     /* functions that call eval or apply (# must match xsubrcnt) */
  77. {    "APPLY",                (FP)xapply         },
  78. {    "CALL-WITH-CURRENT-CONTINUATION",    (FP)xcallcc        },
  79. {    "CALL/CC",                (FP)xcallcc        },
  80. {    "MAP",                    (FP)xmap           },
  81. {    "FOR-EACH",                (FP)xforeach    },
  82. {    "CALL-WITH-INPUT-FILE",            (FP)xcallwi      },
  83. {    "CALL-WITH-OUTPUT-FILE",        (FP)xcallwo      },
  84. {    "LOAD",                    (FP)xload        },
  85. {    "LOAD-NOISILY",                (FP)xloadnoisily},
  86. {    "SEND-SUPER",                (FP)xsendsuper    },
  87. {    "%CLASS-NEW",                (FP)clnew          },
  88. {    "FORCE",                (FP)xforce         },
  89.  
  90.     /* continuations for xsubrs (# must match csubrcnt) */
  91. {    "%MAP1",                (FP)xmap1          },
  92. {    "%FOR-EACH1",                (FP)xforeach1    },
  93. {    "%WITH-FILE1",                (FP)xwithfile1    },
  94. {    "%LOAD1",                (FP)xload1         },
  95. {    "%FORCE1",                (FP)xforce1        },
  96.  
  97.     /* methods */
  98. {    "%CLASS-ISNEW",                clisnew        },
  99. {    "%CLASS-ANSWER",            clanswer    },
  100. {    "%OBJECT-ISNEW",            obisnew        },
  101. {    "%OBJECT-CLASS",            obclass        },
  102. {    "%OBJECT-SHOW",                obshow        },
  103.  
  104.     /* list functions */
  105. {    "CONS",                    xcons        },
  106. {    "CAR",                    xcar        },
  107. {    "CDR",                    xcdr        },
  108. {    "CAAR",                    xcaar        },
  109. {    "CADR",                    xcadr        },
  110. {    "CDAR",                    xcdar        },
  111. {    "CDDR",                    xcddr        },
  112. {    "CAAAR",                xcaaar        },
  113. {    "CAADR",                xcaadr        },
  114. {    "CADAR",                xcadar        },
  115. {    "CADDR",                xcaddr        },
  116. {    "CDAAR",                xcdaar        },
  117. {    "CDADR",                xcdadr        },
  118. {    "CDDAR",                xcddar        },
  119. {    "CDDDR",                xcdddr        },
  120. {    "CAAAAR",                 xcaaaar        },
  121. {    "CAAADR",                xcaaadr        },
  122. {    "CAADAR",                xcaadar        },
  123. {    "CAADDR",                xcaaddr        },
  124. {    "CADAAR",                 xcadaar        },
  125. {    "CADADR",                xcadadr        },
  126. {    "CADDAR",                xcaddar        },
  127. {    "CADDDR",                xcadddr        },
  128. {    "CDAAAR",                xcdaaar        },
  129. {    "CDAADR",                xcdaadr        },
  130. {    "CDADAR",                xcdadar        },
  131. {    "CDADDR",                xcdaddr        },
  132. {    "CDDAAR",                xcddaar        },
  133. {    "CDDADR",                xcddadr        },
  134. {    "CDDDAR",                xcdddar        },
  135. {    "CDDDDR",                xcddddr        },
  136. {    "LIST",                    xlist        },
  137. {    "LIST*",                xliststar    },
  138. {    "APPEND",                xappend        },
  139. {    "REVERSE",                xreverse    },
  140. {    "LAST-PAIR",                xlastpair    },
  141. {    "LENGTH",                xlength        },
  142. {    "MEMBER",                xmember        },
  143. {    "MEMV",                    xmemv        },
  144. {    "MEMQ",                    xmemq        },
  145. {    "ASSOC",                xassoc        },
  146. {    "ASSV",                    xassv        },
  147. {    "ASSQ",                    xassq        },
  148. {    "LIST-REF",                xlistref    },
  149. {    "LIST-TAIL",                xlisttail    },
  150.  
  151.     /* destructive list functions */
  152. {    "SET-CAR!",                xsetcar        },
  153. {    "SET-CDR!",                xsetcdr        },
  154.  
  155.  
  156.     /* symbol functions */
  157. {    "BOUND?",                xboundp        },
  158. {    "SYMBOL-VALUE",                xsymvalue    },
  159. {    "SET-SYMBOL-VALUE!",            xsetsymvalue    },
  160. {    "SYMBOL-PLIST",                xsymplist    },
  161. {    "SET-SYMBOL-PLIST!",            xsetsymplist    },
  162. {    "GENSYM",                xgensym        },
  163. {    "GET",                    xget        },
  164. {    "PUT",                    xput        },
  165.  
  166.     /* environment functions */
  167. {    "THE-ENVIRONMENT",            xtheenvironment    },
  168. {    "PROCEDURE-ENVIRONMENT",        xprocenvironment},
  169. {    "ENVIRONMENT?",                xenvp        },
  170. {    "ENVIRONMENT-BINDINGS",            xenvbindings    },
  171. {    "ENVIRONMENT-PARENT",            xenvparent    },
  172.  
  173.     /* vector functions */
  174. {    "VECTOR",                xvector        },
  175. {    "MAKE-VECTOR",                xmakevector    },
  176. {    "VECTOR-LENGTH",            xvlength    },
  177. {    "VECTOR-REF",                xvref        },
  178. {    "VECTOR-SET!",                xvset        },
  179.  
  180.     /* array functions */
  181. {    "MAKE-ARRAY",                xmakearray    },
  182. {    "ARRAY-REF",                xaref        },
  183. {    "ARRAY-SET!",                xaset        },
  184.  
  185.     /* conversion functions */
  186. {    "SYMBOL->STRING",            xsymstr        },
  187. {    "STRING->SYMBOL",            xstrsym        },
  188. {    "VECTOR->LIST",                xvectlist    },
  189. {    "LIST->VECTOR",                xlistvect    },
  190. {    "STRING->LIST",                xstrlist    },
  191. {    "LIST->STRING",                xliststring    },
  192. {    "CHAR->INTEGER",            xcharint    },
  193. {    "INTEGER->CHAR",            xintchar    },
  194.  
  195.     /* predicate functions */
  196. {    "NULL?",                xnull        },
  197. {    "ATOM?",                xatom        },
  198. {    "LIST?",                xlistp        },
  199. {    "NUMBER?",                xnumberp    },
  200. {    "BOOLEAN?",                xbooleanp    },
  201. {    "PAIR?",                xpairp        },
  202. {    "SYMBOL?",                xsymbolp    },
  203. {    "COMPLEX?",                xrealp        }, /*(1)*/
  204. {    "REAL?",                xrealp        },
  205. {    "RATIONAL?",                xintegerp    }, /*(1)*/
  206. {    "INTEGER?",                xintegerp    },
  207. {    "CHAR?",                xcharp        },
  208. {    "STRING?",                xstringp    },
  209. {    "VECTOR?",                xvectorp    },
  210. {    "PROCEDURE?",                xprocedurep    },
  211. {    "PORT?",                xportp        },
  212. {    "INPUT-PORT?",                xinputportp    },
  213. {    "OUTPUT-PORT?",                xoutputportp    },
  214. {    "OBJECT?",                xobjectp    },
  215. {    "EOF-OBJECT?",                xeofobjectp    },
  216. {    "DEFAULT-OBJECT?",            xdefaultobjectp    },
  217. {    "EQ?",                    xeq        },
  218. {    "EQV?",                    xeqv        },
  219. {    "EQUAL?",                xequal        },
  220.  
  221.     /* arithmetic functions */
  222. {    "ZERO?",                xzerop        },
  223. {    "POSITIVE?",                xpositivep    },
  224. {    "NEGATIVE?",                xnegativep    },
  225. {    "ODD?",                    xoddp        },
  226. {    "EVEN?",                xevenp        },
  227. {    "EXACT?",                xexactp        },
  228. {    "INEXACT?",                xinexactp    },
  229. {    "TRUNCATE",                xtruncate    },
  230. {    "FLOOR",                xfloor        },
  231. {    "CEILING",                xceiling    },
  232. {    "ROUND",                xround        },
  233. {    "1+",                    xadd1        },
  234. {    "-1+",                    xsub1        },
  235. {    "ABS",                    xabs        },
  236. {    "GCD",                    xgcd        },
  237. {    "RANDOM",                xrandom        },
  238. {    "+",                    xadd        },
  239. {    "-",                    xsub        },
  240. {    "*",                    xmul        },
  241. {    "/",                    xdiv        },
  242. {    "QUOTIENT",                xquo        },
  243. {    "REMAINDER",                xrem        },
  244. {    "MIN",                    xmin        },
  245. {    "MAX",                    xmax        },
  246. {    "SIN",                    xsin        },
  247. {    "COS",                    xcos        },
  248. {    "TAN",                    xtan        },
  249. {    "ASIN",                    xasin        },
  250. {    "ACOS",                    xacos        },
  251. {    "ATAN",                    xatan        },
  252. {    "EXP",                    xxexp        },
  253. {    "SQRT",                    xsqrt        },
  254. {    "EXPT",                    xexpt        },
  255. {    "LOG",                    xxlog        },
  256.  
  257.     /* bitwise logical functions */
  258. {    "LOGAND",                xlogand        },
  259. {    "LOGIOR",                xlogior        },
  260. {    "LOGXOR",                xlogxor        },
  261. {    "LOGNOT",                xlognot        },
  262.  
  263.     /* numeric com